<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('月福利历史')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: bootstrap-editable-css"/>
    <th:block th:include="include :: container-css"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: bootstrap-select-css"/>
</head>
<style>
    .fixed-table-container .bs-checkbox .th-inner {
        padding: 8px 8px !important;
    }

    .form-group {
        margin-right: 35px !important;
    }

    .select2 {
        width: 100% !important;
    }

    .select2-dropdown {
        z-index: 99999 !important;
    }


</style>
<body class="gray-bg">

<div class="modal inmodal fade" id="myModal1" tabindex="-1" role="dialog" aria-hidden="true">
    <!--<from>-->
    <!--<div class="modal-dialog modal-sm">-->
    <!--<div class="modal-content">-->
    <!--<div class="modal-header">-->
    <!--<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span-->
    <!--class="sr-only">Close</span>-->
    <!--</button>-->
    <!--<h4 class="modal-title">月福利历史</h4>-->
    <!--</div>-->

    <!--<div class="modal-body">-->
    <!--<p>-->
    <!--<select id="jsid" name='jsid' class="form-control  ">-->

    <!--</select>-->
    <!--</p>-->
    <!--</div>-->
    <!--<div class="modal-footer">-->
    <!--<button type="button" id="close" class="btn btn-white" data-dismiss="modal">关闭</button>-->
    <!--<button type="button" id="determine" onclick="getHistoryData()" class="btn btn-primary">确认</button>-->
    <!--</div>-->
    <!--</div>-->
    <!--</div>-->
    <!--</from>-->
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span
                            class="sr-only">Close</span>
                    </button>
                    <h4 class="modal-title">月福利历史</h4>
                </div>

                <div class="modal-body">
                    <p>
                        <select id="jsid" name='jsid' class="form-control  ">

                        </select>
                    </p>
                </div>
                <div class="modal-footer">
                    <button type="button" id="close" class="btn btn-white" data-dismiss="modal">关闭</button>
                    <button type="button" id="determine" onclick="getHistoryData()" class="btn btn-primary">确认</button>
                </div>
            </div>
        </div>
    </div>
</div>


<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <p>工号：</p>
                            <input type="text" name="badge"/>
                        </li>
                        <li>
                            <p>姓名：</p>
                            <input type="text" name="name"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>


        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>

</body>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: bootstrap-table-editable-js"/>
<th:block th:include="include :: hr-help-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: bootstrap-select-js"/>

<script th:inline="javascript">
    var prefix = ctx + "welfare/calculationHistory";

    $(function () {
        getList();
        $("#myModal1").modal('show');
        $.fn.modal.Constructor.prototype.enforceFocus = function () {
        }
    });

    function getList() {
        var html = "";
        $.ajax({
            async: false,
            url: prefix + "/getBenefitProcess",
            data: {},
            type: "post",
            dataType: "json",
            success: function (data) {
                $("#jsid").empty();
                var arry = data;
                html += "<option value=''></option>"
                for (var i = 0; i < arry.length; i++) {
                    html += "<option value="
                        + arry[i].id
                        + ">"
                        + arry[i].title
                        + "</option>";
                }
                $("#jsid").append(html);

            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.modal.alertWarning("错误,请联系管理员,错误信息:" + textStatus);
            }
        });
    }

    function getHistoryData() {
        var jsid = $("#jsid").val();
        $("#close").click();
        var columns = [];
        var checkbox = {checkbox: true};
        var other;
        var term = {field: 'term', title: '月份'};
        var badge = {field: 'badge', title: '工号'};
        var name = {field: 'name', title: '姓名'};
        var compName = {field: 'compName', title: '公司名称'};
        var depName = {field: 'depName', title: '部门名称'};
        var jobName = {field: 'jobName', title: '工作岗位'};
        var empStatusName = {field: 'empStatusName', title: '员工状态'};
        var jobStatusName = {field: 'jobStatusName', title: '在岗状态'};
        var joinDate = {field: 'joinDate', title: '入职日期'};
        var benefitCity = {field: 'benefitCity', title: '社保缴纳地区'};
        var accuCity = {field: 'accuCity', title: '公积金缴纳地区'};
        var initialized = {
            field: 'initialized',
            title: '冻结',
            formatter: function (value, row, index) {
                if (row.initialized == 1) {
                    return '<i class=\"fa fa-toggle-on text-info fa-2x\" ></i> ';
                } else {
                    return '<i class=\"fa fa-toggle-off text-info fa-2x\" ></i> ';
                }
            }
        };
        columns.push(checkbox, term, badge, name, compName, depName, jobName, empStatusName, jobStatusName, joinDate, benefitCity, accuCity, initialized);
        $.ajax({
            async: false,
            url: ctx + "welfare/calculation/findHeader",
            data: {},
            type: "post",
            dataType: "json",
            success: function (data) {

                for (var i = 0; i < data.length; i++) {
                    other = {
                        field: data[i].title, title: data[i].title

                    }
                    columns.push(other);
                }
                var options = {
                    code: "id",
                    uniqueId: "id",
                    createUrl: prefix + "/process",
                    pagination: false,
                    url: prefix + "/findEmpWelfareHistoryData?jsid=" + jsid,
                    height: $(window).height() - 120,
                    modalName: "福利流程",
                    columns: columns
                };
                $.table.init(options);
            },
        });
    }

</script>
</html>